package com.tanhua.test;

import com.baidu.aip.face.AipFace;
import org.json.JSONObject;

import java.util.HashMap;

public class BaiduFaceTest01 {

    //设置APPID/AK/SK
    public static final String APP_ID = "57486350";
    public static final String API_KEY = "WF2mp0bJprn4cHWIkFGSMz17";
    public static final String SECRET_KEY = "Eo4rdqum2kV3n7NAIcjrBZCxSZn7Q775";

    public static void main(String[] args) {
        // 初始化一个AipFace
        AipFace client = new AipFace(APP_ID, API_KEY, SECRET_KEY);
        // 可选：设置网络连接参数
        client.setConnectionTimeoutInMillis(2000);
        client.setSocketTimeoutInMillis(60000);
        // 调用接口
        String image = "https://ysh-tanhua.oss-cn-beijing.aliyuncs.com/2024/03/21/e45c75f9-a05e-4b2d-b326-03ad1da87ae5.png";
        String imageType = "URL";
        // 传入可选参数调用接口
        HashMap<String, String> options = new HashMap<String, String>();
        options.put("face_field", "age");
        options.put("max_face_num", "2");
        options.put("face_type", "LIVE");
        options.put("liveness_control", "LOW");


        // 人脸检测
        JSONObject res = client.detect(image, imageType, options);
        System.out.println(res.toString(2));

    }


}
